<?php

namespace App\Http\Controllers;

use App\Post;
use App\Topic;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class TopicController extends Controller
{
    public function show(Topic $topic){
        $topic = Topic::withCount('postTopic')->find($topic->id);

        $posts = $topic->posts()->orderBy('created_at', 'desc')->take(10)->get();

        $myposts = Post::authorBy(Auth::id());
        return view('topic/show', compact('topic', 'posts', 'myposts'));
    }

    public function submit(Topic $topic){
        return ;
    }

}
